package shopping

import (
	//"dhfshop/models/member"
	"dhfshop/models/shopping"
	"strconv"
	"dhfshop/controllers/base"
)

type LogisticsController struct {
	base.BaseController
}

// 物流信息管理
func (this *LogisticsController) Get() {
	orderIdStr := this.GetString("order_id")
	if orderIdStr == "" {
		this.ServeError("order_id is null")
		return 
	}
	orderId, err := strconv.ParseInt(orderIdStr, 10, 0)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	}
	order, err := shopping.GetOrderById(orderId)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	}
	trace, err := shopping.GetExpressTraceByShipCode(order.ShippingCode)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	} 
	this.Data["json"] = trace
	this.ServeJSON()
}
